<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Detectlang{
    var $_lang_session = 'front_language';
	var $arr_language = array('vn','english');
    function Detectlang(){
        
    }
    
    function get_lang_data(){
        $CI = &get_instance();
		if(!$CI->session->userdata($this->_lang_session)){
			$CI->session->set_userdata($this->_lang_session, $this->arr_language[0]);	
		}
        return $CI->session->userdata($this->_lang_session);
    }
    
    
    function change_lang($user_lang){
        $CI = &get_instance();
        $CI->session->set_userdata($this->_lang_session, $user_lang);
        $this->forward();
    }
    
    function forward($url = ''){
        $CI = &get_instance();
        if(!empty($url))
            redirect($url);

        if($CI->session->userdata('redirect_page')){
            $url = $CI->session->userdata('redirect_page');
            $CI->session->unset_userdata('redirect_page');
            redirect($url);
        }
        
        redirect('home');
    }
    
    
}
?>